<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Evalformation extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(3)
     *
     * @var int
     */
    protected $_IdEvaform;

    /**
     * Database var type int(3)
     *
     * @var int
     */
    protected $_QuestionnaireIdQestio;

    /**
     * Database var type int(50)
     *
     * @var int
     */
    protected $_SessionformationIdSess;


    /**
     * Parent relation fk_evalformation_questionnaire1
     *
     * @var Application_Model_Questionnaire
     */
    protected $_Questionnaire;

    /**
     * Parent relation fk_evalformation_sessionformation1
     *
     * @var Application_Model_Sessionformation
     */
    protected $_Sessionformation;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_evaform'=>'IdEvaform',
            'questionnaire_id_qestio'=>'QuestionnaireIdQestio',
            'sessionformation_id_sess'=>'SessionformationIdSess',
        ));

        $this->setParentList(array(
            'FkEvalformationQuestionnaire1'=> array(
                    'property' => 'Questionnaire',
                    'table_name' => 'Questionnaire',
                ),
            'FkEvalformationSessionformation1'=> array(
                    'property' => 'Sessionformation',
                    'table_name' => 'Sessionformation',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column id_evaform
     *
     * @param int $data
     * @return Application_Model_Evalformation
     */
    public function setIdEvaform($data)
    {
        $this->_IdEvaform = $data;
        return $this;
    }

    /**
     * Gets column id_evaform
     *
     * @return int
     */
    public function getIdEvaform()
    {
        return $this->_IdEvaform;
    }

    /**
     * Sets column questionnaire_id_qestio
     *
     * @param int $data
     * @return Application_Model_Evalformation
     */
    public function setQuestionnaireIdQestio($data)
    {
        $this->_QuestionnaireIdQestio = $data;
        return $this;
    }

    /**
     * Gets column questionnaire_id_qestio
     *
     * @return int
     */
    public function getQuestionnaireIdQestio()
    {
        return $this->_QuestionnaireIdQestio;
    }

    /**
     * Sets column sessionformation_id_sess
     *
     * @param int $data
     * @return Application_Model_Evalformation
     */
    public function setSessionformationIdSess($data)
    {
        $this->_SessionformationIdSess = $data;
        return $this;
    }

    /**
     * Gets column sessionformation_id_sess
     *
     * @return int
     */
    public function getSessionformationIdSess()
    {
        return $this->_SessionformationIdSess;
    }

    /**
     * Sets parent relation QuestionnaireIdQestio
     *
     * @param Application_Model_Questionnaire $data
     * @return Application_Model_Evalformation
     */
    public function setQuestionnaire(Application_Model_Questionnaire $data)
    {
        $this->_Questionnaire = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_qestio'];
        }

        $this->setQuestionnaireIdQestio($primary_key);

        return $this;
    }

    /**
     * Gets parent QuestionnaireIdQestio
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Questionnaire
     */
    public function getQuestionnaire($load = true)
    {
        if ($this->_Questionnaire === null && $load) {
            $this->getMapper()->loadRelated('FkEvalformationQuestionnaire1', $this);
        }

        return $this->_Questionnaire;
    }

    /**
     * Sets parent relation SessionformationIdSess
     *
     * @param Application_Model_Sessionformation $data
     * @return Application_Model_Evalformation
     */
    public function setSessionformation(Application_Model_Sessionformation $data)
    {
        $this->_Sessionformation = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_sess'];
        }

        $this->setSessionformationIdSess($primary_key);

        return $this;
    }

    /**
     * Gets parent SessionformationIdSess
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Sessionformation
     */
    public function getSessionformation($load = true)
    {
        if ($this->_Sessionformation === null && $load) {
            $this->getMapper()->loadRelated('FkEvalformationSessionformation1', $this);
        }

        return $this->_Sessionformation;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Evalformation
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Evalformation());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Evalformation::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdEvaform() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_evaform = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdEvaform()));
    }
}
